package leetcode100;

// TODO 递归 [经典] 【-】 二叉树的最大深度
// TODO https://leetcode.cn/problems/maximum-depth-of-binary-tree/solution/kan-wan-zhe-ge-shi-pin-rang-ni-dui-di-gu-44uz/

public class lc100_0104 {

    public int maxDepth(TreeNode root) {
        return dfs(root);
    }

    private int dfs(TreeNode node) {
        // 递归终止条件
        if (node == null)
            return 0;

        // 递归
        return Math.max(dfs(node.left), dfs(node.right)) + 1;
    }

}
